#include "stdafx.h"
#include "LineFile.h"

LineFile::LineFile(void)
{
	fp = NULL;
	mLine =0;
}

LineFile::~LineFile(void)
{
}
int LineFile::Open(const char *name)
{
	fp = fopen(name,"r");
	if( fp == NULL ) return 0;
	mLine =0;
	return 1;
}
void LineFile::Close()
{
	if( fp ) fclose(fp);
	fp = NULL;
}
int LineFile::ReadLine()
{
	memset(mData,0,sizeof(mData));
    char * line=fgets(mData,1023,fp);
    if( line == NULL ) return 0;
	mLine ++;
    size_t k = strlen(line);
    if( (line[k-1]== CR)||(line[k-1]== LF) ){
            k--;
            line[k]=0;
    }
    if( (line[k-1]== CR)||(line[k-1]== LF) ){
            k--;
            line[k]=0;
    }
	return 1;
}